package com.annhoa.blog.web;


import com.annhoa.blog.domain.BlogBar;
import com.annhoa.blog.domain.BlogBarnner;
import com.annhoa.blog.domain.BlogOwers;
import com.annhoa.blog.domain.NewBox;
import com.annhoa.blog.domain.Toppic;
import com.annhoa.blog.repository.BlogBarJpaRepository;
import com.annhoa.blog.repository.BlogBarnnerJpaRepository;
import com.annhoa.blog.repository.BlogOwersJpaRepository;
import com.annhoa.blog.repository.NewBoxJpaRepository;
import com.annhoa.blog.repository.ToppicJpaRepository;
import com.annhoa.core.web.BaseController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * 
 * @author annhoa @date2019-11-13
 *
 */
@CrossOrigin
@RestController
public class BarnnerController extends BaseController {
	@Autowired
	private BlogBarnnerJpaRepository blogBarnnerJpaRepository;
	@Autowired
	private BlogBarJpaRepository blogBarJpaRepository;
	@Autowired
	private ToppicJpaRepository toppicJpaRepository;
	@Autowired
	private NewBoxJpaRepository newBoxJpaRepository;
	@Autowired
	private BlogOwersJpaRepository blogOwersJpaRepository;
	
	@RequestMapping(value = "/annhoa-blog/barnnerlist")
	public List<BlogBarnner> listBlogBarnner() {
		List<BlogBarnner> list = blogBarnnerJpaRepository.findAll();
		return list;
	}
	

	@RequestMapping(value = "/annhoa-blog/barlist")
	public List<BlogBar> listBlogBar() {
		List<BlogBar> list = blogBarJpaRepository.findAll();
		return list;
	}
	
	@RequestMapping(value = "/annhoa-blog/toppiclist")
	public List<Toppic> listToppic() {
		List<Toppic> list = toppicJpaRepository.findAll();
		return list;
	}
	@RequestMapping(value = "/annhoa-blog/newboxclist")
	public List<NewBox> listnewbox() {
		List<NewBox> list = newBoxJpaRepository.findAll();
		return list;
	}
	@RequestMapping(value = "/annhoa-blog/blogOwerslist")
	public Optional<BlogOwers> listblogOwers() {
		Optional<BlogOwers> blogOwers = blogOwersJpaRepository.findById((long) 1);
		return blogOwers;
	}
}
